package com.winit.openapi.ups.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.winit.common.query.Page;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ups.spi.systemrule.CityPostCodeService;
import com.winit.ups.spi.systemrule.command.CityPostCodeCommand;
import com.winit.ups.spi.systemrule.vo.CityPostCode;


/**
 * 
 * @author qibin.tang
 *
 */
@Controller
@RequestMapping(value = "/ups/cityPostCode")
public class UpsCityPostCodeController extends BaseController{
    
    
    @Resource
    private CityPostCodeService cityPostCodeService;
    
    /**
     * 查询城市邮编列表
     * @param requestMsg
     * @param responseMsg
     * @return
     */
    @RequestMapping(value = "/queryCityPostCodeList")
    public String queryEorIorList(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	CityPostCodeCommand command = JSON.parseObject(requestMsg.getData().toString(),CityPostCodeCommand.class);
        Page<CityPostCode> list = cityPostCodeService.findCityPostCode(command);
        
        Map<String, Object> data = new HashMap<String, Object>();
        Map<String, Object> page = new HashMap<String, Object>();
        if(list != null){
        	page.put("pageNo", list.getPageable().getPageNumber());
            page.put("pageSize", list.getPageable().getPageSize());
            page.put("totalCount", list.total);
            data.put("list", list.content);
        }
        data.put("pageParams", page);
        responseMsg.setData(data);
        return SUCCESS;
    }
    

}
